package com.tencent.iov.cowin.befsale.clue.controller.clue.assembler;

import com.tencent.iov.cowin.befsale.clue.domain.clue.po.ClueOrder;
import com.software.boot.common.model.dao.BaseAssembler;
import com.software.boot.common.model.rest.BaseRequest;
import com.software.boot.common.model.rest.BaseResponse;
import com.software.common.config.SearchLocalHeader;
import com.software.common.enums.DeleteEnum;
import com.software.common.enums.SCRMRequestHeaderEnum;
import lombok.extern.slf4j.Slf4j;

import java.util.Date;

/**
 * @Author: whp
 * @Date: 2021-12-21 16:16:18
 * @Description: 线索订单表适配器，负责vo<->entity、vo<->po的转换和必要的参数检查，行为
 */
@Slf4j
public class ClueOrderAssembler extends BaseAssembler<BaseResponse, BaseRequest, ClueOrder> {
    public static void initAddClueOrderRequest(ClueOrder request) {
        request.setCorpId(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_CORP_ACCOUNTID.getCode()));
        request.setDealerId(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_DEALER_ID.getCode()));
        request.setTenantId(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_TENANTID.getCode()));
        request.setCreatedBy(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_EMP_ID.getCode()));
        request.setUpdatedBy(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_EMP_ID.getCode()));
        request.setCreatedName(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_EMP_NAME.getCode()));
        request.setUpdatedName(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_EMP_NAME.getCode()));
        request.setDeleted(DeleteEnum.INIT.getFlag());
        request.setCreatedTime(new Date());
        request.setUpdatedTime(new Date());
    }

    public static void initUpdateClueOrderRequest(ClueOrder request) {
        request.setUpdatedBy(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_EMP_ID.getCode()));
        request.setUpdatedName(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_EMP_NAME.getCode()));
    }
}
